<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUserPatientsTable extends Migration
{
    /**
     * Run the migrations.
     * @return void
     */
    public function up()
    {
        Schema::create('st_user_patients', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name', 32)->comment('患者姓名');
            $table->string('phone', 20)->unique();
            $table->string('password');
            $table->float('weight', 5, 1)->default(0.0)->comment('体重kg');
            $table->unsignedSmallInteger('height')->default(0)->comment('身高cm');
            $table->unsignedTinyInteger('age')->comment('年龄');
            $table->float('bmi', 4, 1)->default(0.0)->comment('bmi,小数点后1位');
            $table->unsignedSmallInteger('hypertension')->comment('高血压，收缩压');
            $table->unsignedSmallInteger('hypotension')->comment('低血压，舒张压');
            $table->unsignedSmallInteger('heart_rate')->comment('心率');
            $table->unsignedTinyInteger('sex')->default(0)->comment('性别 0男1女');
            $table->date('birthday')->comment('出生日期');
            $table->unsignedTinyInteger(
                'diabetes_type'
            )->default(0)->comment('0:待查,1:1型, 2:2型,3:妊娠, 4:特殊');

            $table->unsignedTinyInteger(
                'special_illness'
            )->default(0)->comment('0:无, 1:肾透析, 2:肾移植, 3:腹膜透析, 4:癌症放化疗, 5:其他');

            $table->date('illyears')->comment('确诊时间（病史）：年-月-日');
            $table->integer('province')->default(0)->comment('省份');
            $table->integer('city')->default(0)->comment('城市');
            $table->integer('county')->default(0)->comment('区县');
            $table->integer('nation')->default(0)->comment('民族');
            $table->string('invite_code')->comment('邀请码');
            $table->string('invite_original_code')->comment('被邀请码, 邀请人的邀请码');

            $table->unsignedTinyInteger('invite_type')->comment('邀请类型, 1:医生邀请,
                2:好友邀请
            ');

            $table->string('treat_type', 100)->comment('治疗方式：饮食控制,运动控制,口服药,胰岛素,暂无(多个选项用逗号隔开)');
            $table->timestamp('last_login')->comment('最后登录时间');
            $table->string('account', 20)->comment('原表中的account,为了请求数据，以及环信的账号使用');
            $table->string('medical_number')->comment('病案号');
            $table->unsignedTinyInteger('is_gestation')->default(0)->comment('0:无 1：妊娠 2：非妊娠');
            $table->unsignedMediumInteger('hospital_id')->comment('首诊医院');
            $table->unsignedInteger('doctor_id')->comment('首诊医生');
            $table->rememberToken();
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('st_user_patients');
    }
}
